/*     */ package btsm.servlet;
/*     */ 
/*     */ import btsm.bean.excelio;
/*     */ import btsm.bean.sysPro;
/*     */ import java.io.File;
/*     */ import java.io.IOException;
/*     */ import java.io.PrintStream;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Arrays;
/*     */ import javax.servlet.RequestDispatcher;
/*     */ import javax.servlet.ServletException;
/*     */ import javax.servlet.http.HttpServlet;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ 
/*     */ public class ser_btsimport extends HttpServlet
/*     */ {
/*  20 */   private String strpath = "";
/*     */ 
/*     */   public void init() throws ServletException {
/*  23 */     sysPro sPro = new sysPro();
/*  24 */     this.strpath = (sPro.getUploadpath() + "readexcel/");
/*     */   }
/*     */ 
/*     */   public void doGet(HttpServletRequest request, HttpServletResponse response)
/*     */     throws ServletException, IOException
/*     */   {
/*  30 */     excelio EX = new excelio();
/*     */ 
/*  32 */     String seraction = request.getParameter("seraction");
/*     */ 
/*  35 */     String msg = "";
/*  36 */     boolean result = true;
/*     */ 
/*  38 */     ArrayList excel = new ArrayList();
/*     */ 
/*  40 */     if (seraction.equals("serbtsimport")) {
/*  41 */       String[] efilename = { "导出数据＃BTS.xls", "导出数据＃B级防雷器.xls", "导出数据＃变压器.xls", "导出数据＃传输.xls", "导出数据＃电源柜.xls", "导出数据＃动换监控.xls", "导出数据＃固定式油机发电机组.xls", "导出数据＃机房情况.xls", "导出数据＃基站地理环境.xls", "导出数据＃基站供电归属及外聘发电人员联系电话.xls", "导出数据＃交通状况.xls", "导出数据＃交直流配电.xls", "导出数据＃空调.xls", "导出数据＃灭火器.xls", "导出数据＃市电引入.xls", "导出数据＃塔放.xls", "导出数据＃天馈系统.xls", "导出数据＃铁塔.xls", "导出数据＃蓄电池.xls" };
/*  42 */       Arrays.sort(efilename);
/*     */ 
/*  44 */       if ((this.strpath.equalsIgnoreCase("")) || (this.strpath == null)) {
/*  45 */         msg = msg + "设置的Excel文件目录不能为空";
/*     */       }
/*     */       else {
/*  48 */         File d = new File(this.strpath);
/*  49 */         if (d.exists())
/*     */         {
/*  53 */           File[] list = d.listFiles();
/*     */ 
/*  55 */           for (int i = 0; i < list.length; i++) {
/*  56 */             int a = Arrays.binarySearch(efilename, list[i].getName());
/*  57 */             if (a >= 0) {
/*  58 */               excel.add(list[i].getName());
/*     */             }
/*     */           }
/*     */ 
/*  62 */           if (excel.size() == 0)
/*  63 */             msg = msg + "所设置目录没有需要导入数据库的Excel文件！";
/*     */         }
/*     */         else
/*     */         {
/*  67 */           msg = msg + "所设置的Excel文件目录不存在！";
/*     */         }
/*     */ 
/*     */       }
/*     */ 
/*  72 */       if (msg.equals(""))
/*     */       {
/*  75 */         String[] excela = (String[])excel.toArray(new String[0]);
/*     */ 
/*  77 */         int[] row = { 5, 2, 4, 4, 3, 2, 3, 2, 2, 3, 2, 3, 3, 3, 2, 3, 2, 2, 3 };
/*  78 */         int[] col = { 48, 10, 41, 9, 30, 11, 10, 12, 8, 9, 11, 23, 14, 21, 9, 14, 11, 13, 13 };
/*  79 */         String[] ve = { "bts_ve", "hunder_ve", "acdc_ve", "tranff_ve", "trans_ve", "montor_ve", "tran_ve", "dynamo_ve", "psupply_ve", "graph_ve", "magn_ve", "ante_ve", "msupply_ve", "mroom_ve", "firee_ve", "pbox_ve", "airc_ve", "sbattery_ve", "itower_ve" };
/*     */ 
/*  81 */         if (excela.length == 19)
/*     */         {
/*  83 */           for (int i = 0; i < excela.length; i++)
/*     */             try {
/*  85 */               result = Boolean.getBoolean(EX.ReadRowCell(this.strpath + excela[i], row[i], col[i], ve[i]).toString());
/*     */             } catch (Exception ex) {
/*  87 */               ex.printStackTrace();
/*  88 */               System.out.println("读取Excel文件异常错误！");
/*  89 */               result = false;
/*     */             }
/*     */         }
/*     */         else {
/*  93 */           result = false;
/*     */         }
/*     */ 
/*  96 */         if (result) {
/*  97 */           msg = msg + "Excel文件导入数据库成功！";
/*  98 */           request.setAttribute("msg", msg);
/*  99 */           request.setAttribute("filesnames", "list_graph.jsp");
/* 100 */           RequestDispatcher btsm = request.getRequestDispatcher("common.jsp");
/* 101 */           btsm.forward(request, response);
/*     */         } else {
/* 103 */           msg = msg + "Excel文件导入数据库失败！";
/* 104 */           request.setAttribute("msg", msg);
/* 105 */           request.setAttribute("filesnames", "list_graph.jsp");
/* 106 */           RequestDispatcher btsm = request.getRequestDispatcher("common.jsp");
/* 107 */           btsm.forward(request, response);
/*     */         }
/*     */       }
/*     */       else {
/* 111 */         request.setAttribute("msg", msg);
/* 112 */         request.setAttribute("filesnames", "list_graph.jsp");
/* 113 */         RequestDispatcher btsm = request.getRequestDispatcher("common.jsp");
/* 114 */         btsm.forward(request, response);
/*     */       }
/*     */     } else {
/* 117 */       msg = msg + "未能执行Excel文件导入数据库功能！";
/* 118 */       request.setAttribute("msg", msg);
/* 119 */       request.setAttribute("filesnames", "list_graph.jsp");
/* 120 */       RequestDispatcher btsm = request.getRequestDispatcher("common.jsp");
/* 121 */       btsm.forward(request, response);
/*     */     }
/*     */   }
/*     */ 
/*     */   public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
/*     */   {
/* 127 */     doGet(request, response);
/*     */   }
/*     */ 
/*     */   public void destroy()
/*     */   {
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     btsm.servlet.ser_btsimport
 * JD-Core Version:    0.6.2
 */